<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title>Title</title>
    <link rel="stylesheet" href="__CSS__/pintuer.css">
    <link rel="stylesheet" href="__CSS__/admin.css">
    <link rel="stylesheet" href="__STATIC__/css/layui.css">
    <script src="__STATIC__/layui.js"></script>
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/pintuer.js"></script>
</head>
<body>
<form class="layui-form">
    <h3 style="text-align: center;margin-top: 3%;margin-bottom: 2%"><b>紧急事件</b></h3>
    <div class="layui-form-item">
        <div style=" margin-left: 3%" class="layui-inline">
            <lable style="float: left;margin-top: 3%" class="layui-form-lable">
                审批流程：
            </lable>
            <div class="layui-input-inline">
                <select>
                    {volist name="ExigencyFlow" id="vo"}
                    <option value="{$vo.id}">{$vo.flow}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div style=" margin-left: 3%" class="layui-inline">
            <label class="layui-form-label">时间</label>
            <div class="layui-input-block">
                <input value="{$ExigencyInfo.creat_time}" readonly="readonly" lay-verify="required"
                       class="layui-input"  placeholder="yyyy-MM-dd HH:mm:ss"
                       type="text">
            </div>
        </div>
    </div>

            <div style="padding-top: 10px" class="layui-form-item">
                <label style="width: 100px;padding-top: 10px;padding-bottom: 0"
                       class="layui-form-label">付款内容</label>
                <div class="layui-input-block">
                            <textarea style="height: 60px; width: 900px" lay-verify="required" readonly="readonly" placeholder="请输入内容" class="layui-input"
                                      type="text">{$ExigencyInfo.exigency}</textarea>
                </div>
            </div>
    <div style="padding-top: 10px" class="layui-form-item">
        <label style="width: 100px;padding-top: 10px;padding-bottom: 0" class="layui-form-label">审批意见</label>
        <div class="layui-input-block">
            <textarea style="height: 120px; width: 900px" lay-verify="required" placeholder="请输入内容" class="layui-input" type="text" id="audit_opinion"
                      name="audit_opinion"></textarea>
        </div>
        <input type="hidden" value="{$ExigencyInfo.id}" name="id">
    </div>
    <div style="margin-top: 5%;float: right;margin-right: 15%;margin-bottom: 5%">
        <button  id="shenpi" class="layui-btn">审批</button>
        <button  id="bohui" class="layui-btn layui-btn-danger">驳回</button>
        <a class="layui-btn layui-btn-normal" href="{:url('Exigency/exigency_apply_list')}">返回</a>
    </div>
</form>
</body>
<script>
    $(document).on('click', '#shenpi', function () {
        var id = $(" input[ name='id' ] ").val();
        var audit_opinion = $('#audit_opinion').val();
        $.ajax({
            type: "post",
            url: "{:url('Exigency/exigency_apply_agree')}",
            data: {"id": id, 'audit_opinion': audit_opinion},
            dataType: "json",
            success: function (item) {
                //alert(item);
                console.log(item);
                if (item == 1) {
                    layui.use(['layer'], function () {
                        var layer = layui.layer;
                        layer.msg('申请已审批', {icon: 1});
                        setTimeout(function () {
                            //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
                            location = "{:url('Exigency/exigency_apply_list')}";//页面刷新
                        }, 2000);
                        //window.setTimeout(window.location = "{:url('Project/schedule_apply_list')}", 2000);
                    });
                } else if (item == 2) {
                    layui.use(['layer'], function () {
                        var layer = layui.layer;
                        layer.msg('你已经审批完成，请不要重复审批', {icon: 1});
                        setTimeout(function () {
                            //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
                            location = "{:url('Exigency/exigency_apply_list')}";//页面刷新
                        }, 2000);
                        //window.setTimeout(window.location = "{:url('Project/schedule_apply_list')}", 2000);
                    });
                } else if (item == 3) {
                    layui.use(['layer'], function () {
                        var layer = layui.layer;
                        layer.msg('申请已被驳回', {icon: 1});
                    });
                    setTimeout(function () {
                        //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
                        location.reload();//页面刷新
                    }, 2000);
                } else {
                    layui.use(['layer'], function () {
                        var layer = layui.layer;
                        layer.msg('审批未成功', {icon: 2});
                    });
                    //location.reload();
                    setTimeout(function () {
                        //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
                        location.reload();//页面刷新
                    }, 2000);
                }
                /*setTimeout(function () {
                 //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
                 window.location.reload();//页面刷新
                 }, 2000);*/
            }

        });
        return false;
    });
    $(document).on('click', '#bohui', function () {
        var id = $(" input[ name='id' ] ").val();
        var audit_opinion = $('#audit_opinion').val();
        layui.use(['layer'], function () {
            var layer = layui.layer;
            //询问框
            layer.confirm('你确定要驳回？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                $.ajax({
                    type: "post",
                    url: "{:url('Exigency/exigency_apply_disagree')}",
                    data: {"id": id, 'audit_opinion': audit_opinion},
                    dataType: "json",
                    success: function (item) {
                        //console.log(item);
                        if (item == 1) {
                            layui.use(['layer'], function () {
                                var layer = layui.layer;
                                layer.msg('申请已驳回', {icon: 1});
                            });
                        } else if (item == 2) {
                            layui.use(['layer'], function () {
                                var layer = layui.layer;
                                layer.msg('申请已驳回，请不要重复驳回', {icon: 1});
                            });
                        } else if (item == 3) {
                            layui.use(['layer'], function () {
                                var layer = layui.layer;
                                layer.msg('申请已被审批，不能驳回', {icon: 1});
                            });
                        } else {
                            layui.use(['layer'], function () {
                                var layer = layui.layer;
                                layer.msg('驳回未成功', {icon: 2});
                            });
                        }
                    }

                })
            }, function () {
                layer.msg('你取消了驳回', {icon: 1});
            });
        });
        return false;
    });
</script>
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var laydate = layui.laydate;
        var form = layui.form;
        //日期时间选择器
        laydate.render({
            elem: '#time'
            , type: 'datetime'
        });
        //日期时间选择器
        laydate.render({
            elem: '#pay_time'
            , type: 'datetime'
        });
//监听提交
        //监听自定义验证
        form.verify({
            number: [/^[0-9]*$/, '金额只能为数字']
        });
        form.on('submit(demo1)', function (data) {
            /*layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            });*/
            var datas = JSON.stringify(data.field);
            //console.log(datas);
            $.ajax({
                type: "post",
                url: "{:url('Project/schedule_apply_sub')}",
                data: {'data': datas},
                dataType: "json",
                success: function (res) {
                    //alert(res);
                    //console.log(res);
                    if (res == 1) {
                        layer.msg('添加成功');
                        window.setTimeout("window.location=\"{:url('Project/schedule_approve_list')}\"", 2000);
                        //window.location.href="{:url('Stafflist/index')}"
                    } else {
                        layer.msg('提示：添加失败');
                    }
                }
            });
            return false;
        });
    });
</script>
</html>